POV-Ray : Newsgroups : povray.general : Field of View : Re: Field of View Server Time
7 Aug 2024 17:27:02 EDT (-0400)
  Re: Field of View  
From: David Fontaine
Date: 5 Aug 2001 17:32:10
Message: <3B6DB942.CE717D93@faricy.net>
Andrew wrote:
> 
> OK, I know I'm being lazy here, but my maths isn't that hot...
> 
> Can anyone tell me how I would go about determining if a point will be
> in view given its coordinates and the camera's parameters?  See, I'm
> making Antoine's necklace, a fractal object involving a very large
> number of primitives, and they take up way too much memory, but many are
> off the screen.

I wrote a macro to find the angle between two vectors.


#macro vangle(vec1,vec2)
   #local len1 = vlength(vec1);
   #local len2 = vlength(vec2);
   #local len3 = vlength(vec2-vec1);
   acos((pow(len3,2)-pow(len1,2)-pow(len2,2))/(-2*len1*len2))
#end


So find the angle between the vector

   object position - camera position

and the vector

   camera look_at - camera position (or just camera direction)

and check if the angle is larger than your viewing angle.  Since the
camera angle goes to the edge of the pic, not the corner, you need a
bigger angle than the actual camera angle.  I think this should do it:

   atan(sqrt((1 + pow(image_height/image_width, 2)) *
pow(tan(camera_angle), 2)))

And of course you have to add a little padding for the width of the
objects...

Of course, this tells you if the object is in a cone around the field of
view, but it can be in the cone and outside the image.  So it's not 100%
efficient, but it'll work (I think).

-- 
David Fontaine  <dav### [at] faricynet>  ICQ 55354965
My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.